import sqlite3


def main():
    print('main')
    readSqlite()


def readSqlite():
    sqlConnection = sqlite3.connect('/home/ubuntu/user_space/dbRotateBack.sqlite')

    print('success')

    cursor = sqlConnection.execute('Select * from SDC_1c637e22c666b482SensorAccelerometerData;')
    timestamp_a, acce_x, acce_y, acce_z = [], [], [], []
    for row in cursor:
        timestamp_a.append(row[1])
        acce_x.append(row[2])
        acce_y.append(row[3])
        acce_z.append(row[4])

    # print(acce_x)

    cursor = sqlConnection.execute('Select * from SDC_1c637e22c666b482SensorGyroscopeData;')
    timestamp_g, gyro_x, gyro_y, gyro_z = [], [], [], []
    for row in cursor:
        timestamp_g.append(row[1])
        gyro_x.append(row[2])
        gyro_y.append(row[3])
        gyro_z.append(row[4])

    # print(gyro_x)

    cursor = sqlConnection.execute('Select * from SDC_1c637e22c666b482SensorLinearAccelerationData;')
    timestamp_l, line_x, line_y, line_z = [], [], [], []
    for row in cursor:
        timestamp_l.append(row[1])
        line_x.append(row[2])
        line_y.append(row[3])
        line_z.append(row[4])

    print(timestamp_l)
    ## zheli yinggai jiequ gyro kaishi weizhi
    return [timestamp_a, acce_x, acce_y, acce_z], [timestamp_g, gyro_x, gyro_y, gyro_z], [timestamp_l, line_x, line_y, line_z]



if __name__ == '__main__':
    main()
